package com.wtf.generator.support;

import com.baomidou.mybatisplus.annotation.DbType;
import com.wtf.generator.enums.CommonErrorEnum;
import com.wtf.generator.enums.DbTableSqlRepository;
import com.wtf.generator.enums.TableApi;
import com.wtf.generator.exception.CommonException;
/**
 * date: 2022/6/18 10:59
 * @author linhuanyou
 * @email 496558736@qq.com
 * @version 1.0
 */
public class DbSqlRepositorySupport implements DbTableSqlSupport {
    @Override
    public String execSql(DbType dbType, TableApi tableApi) {
        DbTableSqlRepository dbTableSqlRepository = DbTableSqlRepository.valueOf(dbType);
        String execSql = null;
        switch (tableApi) {
            case TABLElIST:
                execSql = dbTableSqlRepository.getTableList();
                break;
            case TABLE:
                execSql = dbTableSqlRepository.getTable();
                break;
            case COLUMNS:
                execSql = dbTableSqlRepository.getColumns();
                break;
            default:
                throw new CommonException(CommonErrorEnum.ERROR_VALID);
        }
        return execSql;
    }
}
